<template>
  <div>
    <div>
      <a-button type="primary" icon="plus" style="margin: 10px" @click="addXfj()">新增</a-button>
      <a-button type="primary" icon="upload" style="margin: 10px" @click="upload">导入</a-button>
    </div>
    <a-table
      rowKey="id"
      ref="table"
      size="middle"
      bordered
      :columns="columns"
      :dataSource="dataSource">
      <span slot="action" slot-scope="text,record">
        <a v-show="record.type==2" @click="deleteZdj(record)">删除</a>
      </span>
    </a-table>
    <UploadExcel ref='uploadExcel' v-on:Refresh="Refresh"></UploadExcel>
    <AddXfj ref='addXfj' v-on:Refresh="Refresh"></AddXfj>
  </div>
</template>

<script>
import EpaWeekly from "../../../../myService/EpaWeekly";
import UploadExcel from '../../../../views/epa/epa-weekly/Modal/UploadExcel'
import AddXfj from '../../../../views/epa/epa-weekly/Modal/AddXfj'
export default {
  name: "Step4",
  components:{
    UploadExcel,
    AddXfj
  },
  data(){
    return{
      reportId:0,
      dataSource:[],
      columns: [
        {
          title: '#',
          dataIndex: '',
          key:'rowIndex',
          width:60,
          align:"center",
          customRender:function (t,r,index) {
            return parseInt(index)+1;
          }
        },
        {
          title:'区域',
          align:"center",
          dataIndex: 'problemTerritory'
        },
        {
          title:'信访编号',
          align:"center",
          dataIndex: 'xfjbh'
        },
        {
          title:'反映内容',
          align:"center",
          dataIndex: 'content'
        },
        {
          title:'承办单位',
          align:"center",
          dataIndex: 'organizer'
        },
        {
          title:'类型',
          align:"center",
          dataIndex: 'contentType'
        },
        {
          title:'列为重要信访件理由',
          align:"center",
          dataIndex: 'reason'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align:"center",
          fixed:"right",
          width:147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      check:[]
    }
  },
  methods:{
    deleteZdj(record){
      console.log(record)
      var xfjbhList=(record.xfjbh).split("、");
      console.log(xfjbhList)
      EpaWeekly.deleteZdj({id:record.id}).then((res)=>{
        console.log(res)
        this.Refresh()
      })
    },
    loading(model){
      this.reportId=model.id;
      console.log(model.id)
      this.reportId=model.id;
      EpaWeekly.getFocusOrder({reportId:this.reportId}).then((res)=>{
        console.log("ddsdsdsd")
        console.log(res)
        this.dataSource=res.result;
      })
    },
    Refresh(){
      console.log("888888888")
      EpaWeekly.getFocusOrder({reportId:this.reportId}).then((res)=>{
        console.log("ddsdsdsd")
        console.log(res)
        this.dataSource=res.result;
        console.log(this.dataSource)
        this.check=[]
        for(let i=0;i<this.dataSource.length;i++){
          console.log(i)
          let xfjbhList=(this.dataSource[i].xfjbh).split("、");
          for(var j=0;j<xfjbhList.length;j++){
            (this.check).push(xfjbhList[j])
          }
          console.log(this.check);
        }
      })
    },
    upload(){
      this.$refs.uploadExcel.open(this.reportId);
    },
    addXfj(){
      console.log("dsddsd")
      this.$refs.addXfj.open(this.reportId,this.check);
    }
  }
}
</script>

<style scoped>

</style>